package com.area.cth.service.impl;

import com.area.cth.mapper.ThumbMapper;
import com.area.cth.pojo.Thumb;
import com.area.cth.service.ThumbService;
import com.area.cth.utils.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class ThumbServiceImpl implements ThumbService {
    @Autowired
    private ThumbMapper tm;

    @Override
    public void addLike(Integer pId) {
        Map<String,Object> map = ThreadLocalUtil.get();
        Integer uId = (Integer) map.get("id");
        tm.addLike(pId,uId);
    }

    @Override
    public Thumb likeIf(Integer pId) {
        Map<String,Object> map = ThreadLocalUtil.get();
        Integer uId = (Integer) map.get("id");
        return tm.likeIf(pId,uId);
    }

    @Override
    public void deleteLike(Integer lId) {
        tm.deleteLike(lId);
    }

    @Override
    public Integer thumbCount(Integer pId) {
        return tm.thumbCount(pId);
    }
}
